package com.example.yk_fx.live;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.bumptech.glide.Glide;
import com.example.yk_fx.R;
import com.example.yk_fx.entity.GiftEntity;

public class GiftView extends LinearLayout {
    TextView tvUser,tvGiftname,tvCount;
    ImageView ivGiftPath;
    public GiftView(Context context) {
        super(context);
    }

    public GiftView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        View view = LayoutInflater.from(context).inflate(R.layout.gift_layout, null);
        tvUser = view.findViewById(R.id.tv_user);
        tvGiftname = view.findViewById(R.id.tv_giftname);
        tvCount = view.findViewById(R.id.tv_count);
        ivGiftPath = view.findViewById(R.id.iv_giftpath);
        addView(view);
    }

    public GiftView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    public GiftView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    public void loadUser(String name){
        tvUser.setText(name);
    }
    public void loadGift(GiftEntity.DataBean entity){
        tvGiftname.setText(entity.getGiftname());
        Glide.with(getContext()).load(entity.getGiftpath()).into(ivGiftPath);
    }
    public void loadCount(int count){
        tvCount.setText("X"+count);
    }
}
